WriteToFile field 1,FALSE,"WriteToFile Docs",FALSE,"MSWD"
put the result
end mouseUp
-- part 7 (field)
-- low flags: 81
-- high flags: 2007
-- rect: left=12 top=26 right=298 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 22
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Source
-- part 8 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=299 top=300 right=322 bottom=438
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show Pascal Source
----- HyperTalk script -----
on mouseUp
set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide Pascal Source"
else set the name of me to "Show Pascal Source"
end mouseUp
-- part contents for background part 16
----- text -----
WRITETOFILE XCMD version 1.0
Kevin Calhoun
The WriteToFile XCMD writes the contents of a HyperCard container to a text file. The file may be designated by its full pathname, or it may be given by the user in a standard file dialog. WriteToFile can append to an existing file, replace an existing file, or create a new file.
Use some caution when using WriteToFile. It will overwrite or append to a file you designate by full pathname even if that file is better off left alone. It does not check whether an existing file is a TEXT file.
If an error occurs, WriteToFile returns an error message as the Result. Word 1 of this message will be "Error." If the file was written successfully, WriteToFile returns the full pathname of the file as the Result.
The first parameter, container, is the name of a HyperTalk container. This can be a field, a variable, a function, or, in sum, anything you can "get". For example,
WriteToFile card field 1
will write the contents of card field 1 to a file, while
WriteToFile containerName
will write the contents of the HyperTalk variable called "containerName" to a file.
The second parameter, usePathname, tells WriteToFile how to interpret the third parameter. If usePathname is TRUE, WriteToFile attempts to write to the file whose full pathname is given in parameter 3. If usePathname is false, WriteToFile invokes standard file with the contents of parameter 3 given as the default name for the file. If standard file is invoked and the user pushes the cancel button in the dialog box, FileToField returns "Cancel" as the Result.
If the fourth parameter, append, is TRUE, WriteToFile appends to the file rather than replacing its contents. Note that this parameter has no significance unless the WriteToFile is writing to an existing file designated by full pathname.
If you want to be able to open your favorite word processor by double-clicking in the Finder on the text file that WriteToFile creates, you must supply the creator parameter. For MacWrite, the creator is "MACA." For Microsoft Word, the creator is "MSWD." If you don't specify a creator, WriteToFile will default to MACA. Note that this parameter is not significant unless WriteToFile is creating a new file. The creator of an existing file will not be changed.
EXAMPLES
WriteToFile bkgnd field id 3 -- standard file will be invoked
WriteToFile card field 5,TRUE,"TheFattaTheLand:Of Mice And Men:My Book Report"
WriteToFile variableName,TRUE,"MyHD:MyFile",TRUE -- append to existing file
REVISION HISTORY
30 April 1989 1.0
NOTE TO USERS OF FIELDTOFILE: WriteToFile does everything that FieldToFile could do, except that it can't write to an AppleShare drop folder. The parameter list is quite different; the most important difference is that, when using WriteToFile, you must not put a field designation in quotation marks.
-- part contents for card part 7
----- text -----
UNIT DisksEngravedWhileUWait;
{ WriteToFile XCMD © 1988-1989 by the Trustees of Dartmouth College }